#!/bin/bash

# 设置工作目录和输出目录
workdir=~/braindata/CCNP-20241104
NIFTI_DIR=${workdir}/nifti1
sub_list=${workdir}/test1/subs.list

# 读取被试列表到数组
mapfile -t subjects < "$sub_list"

# 遍历每个被试
for subj in "${subjects[@]}"
do
    subj_data=${workdir}/test1/${subj}
    output_dir=${NIFTI_DIR}/${subj}

    # 创建输出目录
    mkdir -p "$output_dir"

    echo "Converting ${subj_data} to ${output_dir}"

    # 使用 dcm2niix 进行转换
    dcm2niix -z y -b y -o "$output_dir" "$subj_data"
done
